/*
 * libmanyuc - Architecture independent debounce
 * Copyright (C) 2013 - Margarita Manterola Rivero
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.    See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301 USA
 */

#include "debounce.h"
#include "io.h"
#include "timers.h"
#include <stdlib.h>

int Pin_Read_Debounce_SW(Pin_t pin) {
    uint8_t old_value = 2;
    uint8_t new_value = Pin_Read(pin);
    while (old_value != new_value) {
        Delay_ms(5);
        old_value = new_value;
        new_value = Pin_Read(pin);
    }
    return new_value;
}

// vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
